<!-- 申请结果页 -->
<template>
  <view v-if="shenheStatus == 0 && requestEnd" class="result-page" >
    <view class="result-section">
      <view class="pending">
        <view class="icon-box">
          <i
            class="iconfont icon-clock-fill"
            :class="[status == 1 ? 'icon-success-fill' : '']"
          ></i>
        </view>
        <view class="status-text">{{ statusTitle[status] }}</view>
        <view class="status-info">{{ statusMsg[status] }}</view>
      </view>
    </view>
    <view class="page-btn" @click="toBack">
      {{ $t('mdAdmin.back') + '（' + countdownText + '）' }}
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components: { Shenhe },
  data() {
    return {
      countdownText: 5,
      status: 0,
      requestEnd: false,
      statusTitle: [
        this.$t('mdAdmin.checkStatus1'),
        this.$t('mdAdmin.checkStatus2'),
        this.$t('mdAdmin.checkStatus3'),
      ],
      statusMsg: [
        this.$t('mdAdmin.statusMsg1'),
        this.$t('mdAdmin.statusMsg2'),
        this.$t('mdAdmin.statusMsg3'),
      ],
    };
  },
  onLoad(t) {
    uni.showLoading({
      title: this.$t('home.loading'),
    });
    this.$allrequest.shareholder.applyStatus().then(res => {
      uni.hideLoading();
      if (!res.code) {
        this.requestEnd = true;
        this.status = res.data.status;
        this.timer = setInterval(() => {
          this.countdownText--;
          if (this.countdownText <= 0) {
            clearInterval(this.timer);
            if (this.status == 2) {
              this.$utils.toUrl('/shareholder/apply/apply', 'redirectTo');
              return;
            }
            uni.navigateBack();
          }
        }, 1000);
      } else {
        uni.showToast({
          title: res.msg,
          icon: 'none',
        });
        setTimeout(() => {
          uni.navigateBack();
        }, 1500);
      }
    }).catch(()=>{
      uni.hideLoading();
    });
  },
  computed: {},
  onShow() {},
  watch: {},
  methods: {
    // 点击返回按钮
    toBack() {
      if (this.status == 2) {
        this.$utils.toUrl('/shareholder/apply/apply', 'redirectTo');
        return;
      }
      uni.navigateBack();
    },
  },
  onUnload() {
    if (this.timer) clearInterval(this.timer);
  },
};
</script>

<style lang="scss" scoped>
.result-page {
  width: 100%;
  background: #f2f2f2;
  min-height: 100vh;
  .result-section {
    background: #ffffff;
    .pending {
      padding-top: 30rpx;
      padding-bottom: 70rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
      .icon-box {
        width: 130rpx;
        height: 130rpx;
        background: #ffffff;
        border-radius: 50%;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        .iconfont {
          color: #f0250e;
          font-size: 190rpx;
        }
      }
      .status-text {
        font-size: 40rpx;
        font-family: PingFang SC;
        font-weight: 600;
        color: #262626;
        margin-top: 32rpx;
      }
      .status-info {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        margin-top: 20rpx;
      }
    }
  }
  .page-btn {
    width: 678rpx;
    height: 88rpx;
    background: #f0250e;
    border-radius: 44rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #ffffff;
    margin: 80rpx auto 40rpx;
  }
}
</style>
